# import requests
# import json
# import baozou_insert_sql
# Platform = "追书云"
# def zhuishuyun():
#     r = requests.session()
#     url="https://channel.zhuishuyun.com/api/auth/login"
#     data={
#         'Content-Disposition: form-data; name="phone"': '18625962655',
#         'Content-Disposition: form-data; name="number"':'undefined',
#         'Content-Disposition: form-data; name="password"':'qwerasdf66',
#
#     }
#     rr = r.post(url=url,data=data)
#     # print(rr.text)
#     header = {
#         "cookie": "laravel_session=eyJpdiI6IjdnclpoZlh0a2l5TW84YzRRNzhsVGc9PSIsInZhbHVlIjoieldkYWJ3XC9rUG43eWo0YXdOWXc4K2JETTF0WEU2eE9GVlN1aXRabnRiQ01zTzlEaEdLNHRWM25mNFB2TVNoVDhLUTVKSXI5RWVFYzFjSFBLYzNBTDR3PT0iLCJtYWMiOiJjNWExYzk0NDM4NTcxOTFmMjdiYmI2ZTM2YzU5MmQxYzI4ZDYwYmUwZjdjZTkxODBlYzQ0YjViM2Q5MDYyMGFkIn0%3D",
#         "referer": "https://channel.zhuishuyun.com/statisticsState",
#         "user-agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36"
#     }
#     aa = r.get(url="https://channel.zhuishuyun.com/api/trade/orderDayStats",headers = header)
#     # print(aa.text)
#     html = json.loads(aa.text)
#     date_time = html["data"]["list"][0]["date"]
#     Amount_share = int(html["data"]["list"][0]["total_recharge_amount"])*0.9
#     Amount_share = round(Amount_share, 2)
#     baozou_insert_sql.baozou_spider_everyday_sum(date_time,Amount_share,Platform)


from selenium import webdriver
import baozou_insert_sql
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
Platform = "追书云"
def zhuishuyun():
    driver = webdriver.Chrome(r'D:\Program Files\python3.63\chromedriver.exe')
    driver.get("https://channel.zhuishuyun.com/passport/login")
    driver.maximize_window()
    driver.implicitly_wait(10)
    time.sleep(1)

    # 定位账号
    driver.find_element_by_xpath('//div[1]/div/div/input').clear()
    driver.find_element_by_xpath('//div[1]/div/div/input').send_keys('{0}'.format(""))

    # 定位密码
    time.sleep(0.5)
    driver.find_element_by_xpath('//div[2]/div//input').clear()
    driver.find_element_by_xpath('//div[2]/div//input').send_keys('{0}'.format(''))

    # 点击登录
    time.sleep(1)
    driver.find_element_by_xpath('//span').click()
    # time.sleep(1)
    try:
        WebDriverWait(driver,15).until(
            EC.element_to_be_clickable((By.XPATH,'//div[3]/div/div[1]//i'))
        )
        driver.find_element_by_xpath('//div[3]/div/div[1]//i').click()
    except Exception:
        print("00")
    time.sleep(0.5)
    driver.find_element_by_xpath('//span[text()="充值统计"]').click()
    time.sleep(0.5)
    driver.find_element_by_xpath('//li[2]//li[1]').click()
    time.sleep(0.5)
    date_time = driver.find_element_by_xpath('//tr[1]/td[1]/div').text
    Amount_share = driver.find_element_by_xpath('//tr[1]/td[2]/div').text
    Amount_share = float(Amount_share)*0.9
    Amount_share = round(Amount_share, 2)
    baozou_insert_sql.baozou_spider_everyday_sum(date_time, Amount_share, Platform)
    # print(date_time,Amount_share)
    driver.quit()



